Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.wpi.cetask
Class Task

    java.lang.Object
      edu.wpi.cetask.Task

Direct Known Subclasses:
  Decomposition.Step

    public class Task

extends Object

Field Summary
`protected javax.script.Bindings` | `bindings`
`protected TaskEngine` | `engine`

Method Summary
`boolean` | `checkSlotValue(String name, Object value)`
`boolean` | `checkSlotValueScript(String name, String expression)`
`boolean` | `copySlotValue(Task task, String name)` If named slot of this task is defined, copy value to corresponding slot of given task.
`boolean` | `copySlotValues(Task task)` Copies the values of defined slots from this task to given task.
`void` | `deleteSlotValue(String name)` Make named slot undefined.
`protected Object` | `eval(String script, javax.script.Bindings extra, String where)`
`protected Object` | `eval(String expression, String where)`
`protected Boolean` | `evalCondition(String expression, String where)`
`String` | `format()`
`List<DecompositionClass>` | `getDecompositions()`
`Boolean` | `getExternal()` Get the value of the predefined 'external' slot.
`String` | `getProperty(String key)`
`Script` | `getScript()` Return appropriate and applicable script to ground this task, or null if none.
`Object` | `getSlotValue(String name)` Return value of the named slot. Note that this method returns a Java object, but the real values are stored in JavaScript and must be converted to Java objects when returned by this method.
`String` | `getSlotValueToString(String name)` Return the string obtained by calling toString method (in JavaScript) on value of named slot.
`Boolean` | `getSuccess()` Get the value of the predefined 'success' slot
`TaskClass` | `getType()`
`long` | `getWhen()` Get time when this task occurred, if it did.
`Boolean` | `isAchieved()`
`Boolean` | `isApplicable()`
`boolean` | `isDefinedInputs()` Test whether all declared input slots (i.e., not including "external") have defined values.
`boolean` | `isDefinedOutputs()` Test whether all declared output slots (i.e., not including "success" and "when") have defined values.
`boolean` | `isDefinedSlot(String name)` Test whether slot value is defined.
`boolean` | `matches(Task task)` Test whether given task instance matches this task instance.
`boolean` | `occurred()` Test whether this task instance occurred.
`void` | `setBooleanSlotValue(String name, Boolean value)` Like setSlotValue(), but results in boolean JavaScript value.
`void` | `setExternal(boolean external)` Set the predefined 'success' output slot of this task.
`void` | `setIntSlotValue(String name, Integer value)` Like setSlotValue(), but results in JavaScript number value.
`void` | `setSlotValue(String name, Object value)` Set the value of named slot to given value. Note that the given Java object must be converted to a JavaScript object for storage.
`void` | `setSlotValueScript(String name, String expression, String where)` Set the value of named slot to result of evaluating given JavaScript expression.
`void` | `setStringSlotValue(String name, String value)` Like setSlotValue(), but results in JavaScript string value.
`void` | `setSuccess(boolean success)` Set the predefined 'success' output slot of this task.
`void` | `setWhen(long milliseconds)` Set the time when this task occurred.
`String` | `toString()`
`protected String` | `toStringVerbose()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### engine

    protected final TaskEngine engine

### bindings

    protected final javax.script.Bindings bindings

Method Detail

### getType

    public TaskClass getType()

### getSlotValue

    public Object getSlotValue(String name)

  Return value of the named slot.
  Note that this method returns a Java object, but the real values are stored in JavaScript and must be converted to Java objects when returned by this method. Refer to Chapter 12 of O'Reilly JavaScript guide for details of conversion, but note following subtleties here:
  - JavaScript objects and arrays (i.e., everything except for numbers, strings and booleans) convert to Java objects of "opaque" type. These values can be passed back to JavaScript, but have an unpublished API that is not intended for use by Java programs.
  - Both null and undefined in JavaScript convert to null
  Since there is no attribute for "optional" slots in CEA-2018, all input slot values must be defined before executing a task and all output slots will be defined after execution. However, a null value can be used unless a pre- or postcondition specifies otherwise.

  See Also:
    `isDefinedSlot(String)`, `deleteSlotValue(String)`, `isDefinedInputs()`, `isDefinedOutputs()`

### getSlotValueToString

    public String getSlotValueToString(String name)

  Return the string obtained by calling toString method (in JavaScript) on value of named slot. Good for debugging output.

### isDefinedSlot

    public boolean isDefinedSlot(String name)

  Test whether slot value is defined. Note if getSlotValue() returns null, isDefinedSlot() may return true or false.

  See Also:
    `getSlotValue(String)`, `deleteSlotValue(String)`

### setSlotValue

    public void setSlotValue(String name,
                             Object value)

  Set the value of named slot to given value.
  Note that the given Java object must be converted to a JavaScript object for storage. Refer to Chapter 12 of O'Reilly JavaScript guide for details of conversion, but note following subtleties here:
  - Java objects and arrays (i.e., everything but numbers and booleans) convert to instances of JavaObject and JavaArray
  - Specifically, Java strings convert to instances of JavaObject (not JavaScript strings!)

  See Also:
    `getSlotValue(String)`, `setSlotValueScript(String,String,String)`

### checkSlotValue

    public boolean checkSlotValue(String name,
                                  Object value)

### setBooleanSlotValue

    public void setBooleanSlotValue(String name,
                                    Boolean value)

  Like setSlotValue(), but results in boolean JavaScript value. Convenience method which calls setSlotValueScript.

  See Also:
    `setSlotValue(String,Object)`, `setSlotValueScript(String,String,String)`

### setIntSlotValue

    public void setIntSlotValue(String name,
                                Integer value)

  Like setSlotValue(), but results in JavaScript number value. Convenience method which calls setSlotValueScript.

  See Also:
    `setSlotValue(String,Object)`, `setSlotValueScript(String,String,String)`

### setStringSlotValue

    public void setStringSlotValue(String name,
                                   String value)

  Like setSlotValue(), but results in JavaScript string value. Convenience method which calls setSlotValueScript.

  See Also:
    `setSlotValue(String,Object)`, `setSlotValueScript(String,String,String)`

### setSlotValueScript

    public void setSlotValueScript(String name,
                                   String expression,
                                   String where)

  Set the value of named slot to result of evaluating given JavaScript expression. This method avoids issues of conversion from Java to JavaScript objects.

  See Also:
    `setSlotValue(String,Object)`

### checkSlotValueScript

    public boolean checkSlotValueScript(String name,
                                        String expression)

### deleteSlotValue

    public void deleteSlotValue(String name)

  Make named slot undefined.

  See Also:
    `isDefinedSlot(String)`

### isApplicable

    public Boolean isApplicable()

### isAchieved

    public Boolean isAchieved()

### isDefinedInputs

    public boolean isDefinedInputs()

  Test whether all declared input slots (i.e., not including "external") have defined values.

  See Also:
    `getSlotValue(String)`

### isDefinedOutputs

    public boolean isDefinedOutputs()

  Test whether all declared output slots (i.e., not including "success" and "when") have defined values.

  See Also:
    `getSlotValue(String)`

### getWhen

    public long getWhen()

  Get time when this task occurred, if it did.

  Returns:
    milliseconds or 0 (if not occurred)
  See Also:
    `setWhen(long)`

### setWhen

    public void setWhen(long milliseconds)

  Set the time when this task occurred. Javascript instance of Date object is created with given milliseconds.

  See Also:
    `getWhen()`

### occurred

    public boolean occurred()

  Test whether this task instance occurred.

### getSuccess

    public Boolean getSuccess()

  Get the value of the predefined 'success' slot

  Returns:
    TRUE, FALSE or null

### setSuccess

    public void setSuccess(boolean success)

  Set the predefined 'success' output slot of this task.

  Parameters:
    `success` - - note type boolean so converts to JavaScript boolean

### getExternal

    public Boolean getExternal()

  Get the value of the predefined 'external' slot.

  Returns:
    TRUE, FALSE or null

### setExternal

    public void setExternal(boolean external)

  Set the predefined 'success' output slot of this task.

  Parameters:
    `external` - - note type boolean so converts to JavaScript boolean

### getDecompositions

    public List<DecompositionClass> getDecompositions()

### getScript

    public Script getScript()

  Return appropriate and applicable script to ground this task, or null if none.

### matches

    public boolean matches(Task task)

  Test whether given task instance matches this task instance. Two task instances match (symmetric relationship) iff they are both instances of the same type and the values of each corresponding slot are either equal or one is undefined.

  See Also:
    `copySlotValues(Task)`

### copySlotValues

    public boolean copySlotValues(Task task)

  Copies the values of defined slots from this task to given task. Note this side-effects the given task and will overwrite existing slot values.

  Parameters:
    `task` - - task of same type
  Returns:
    true if any slots of given task overwritten (were defined)
  See Also:
    `matches(Task)`

### copySlotValue

    public boolean copySlotValue(Task task,
                                 String name)

  If named slot of this task is defined, copy value to corresponding slot of given task.

  Parameters:
    `task` - - task of same type
  Returns:
    true if slot of given task is overwritten (was defined)

### toStringVerbose

    protected String toStringVerbose()

### format

    public String format()

### getProperty

    public String getProperty(String key)

### eval

    protected Object eval(String expression,
                          String where)

### eval

    protected Object eval(String script,
                          javax.script.Bindings extra,
                          String where)
                   throws javax.script.ScriptException

  Throws:
    `javax.script.ScriptException`

### evalCondition

    protected Boolean evalCondition(String expression,
                                    String where)

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD